import java.net.URL;

import javax.swing.ImageIcon;

import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
import com.jmex.terrain.TerrainBlock;
import com.jmex.terrain.util.ImageBasedHeightMap;
import com.jmex.terrain.util.MidPointHeightMap;
import com.jmex.terrain.util.ProceduralTextureGenerator;


public class Terreno extends SimpleGame {
    public static void main(String[] args) {
        Terreno app = new Terreno();
        app.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }

    protected void simpleInitGame() {
        // o mapa do terreno
	int[] map=new int[]{
            1,1,1,1,1,1,1,1,
            1,1,1,1,1,1,1,1,
            1,1,2,2,2,1,1,1,
            1,1,2,5,2,1,1,1,
	    1,1,2,2,2,1,1,1,
	    1,1,1,1,1,0,0,0,
	    1,1,1,1,1,0,-1,0,
	    1,1,1,1,1,0,0,0
        };
	
	// a imagem que será colocada como textura
	ImageIcon hexImage = new ImageIcon("hex.png");
	
	// a textura
	Texture hexTexture = TextureManager.loadTexture(hexImage.getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
	hexTexture.setWrap(Texture.WM_WRAP_S_WRAP_T);
	hexTexture.setScale(new Vector3f(8f,8f,1f));
	

        TerrainBlock tb=new TerrainBlock("block",8, new Vector3f(2,1,2), map, new Vector3f(0,0,0), false);

	TextureState ts = display.getRenderer().createTextureState();
	ts.setTexture(hexTexture);
	tb.setRenderState(ts);

        // Give the terrain a bounding box.
        tb.setModelBound(new BoundingBox());
        tb.updateModelBound();

        // Attach the terrain TriMesh to rootNode
        rootNode.attachChild(tb);
    }
}
